package com.fenghongzhang.day013.mvp.presenter;

import android.util.Log;

import com.fenghongzhang.day013.entity.Meizi;
import com.fenghongzhang.day013.mvp.contract.MeiziContract;
import com.fenghongzhang.lib.mvp.presenter.BasePresenter;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

//让view 和model
public class MeiziPresenter extends BasePresenter<MeiziContract.IMeiZiModel,MeiziContract.IMeiziView> {


    private static final String TAG = "MeiziPresenter";
    public MeiziPresenter(MeiziContract.IMeiZiModel mModel, MeiziContract.IMeiziView mView) {
        super(mModel, mView);
    }

    //view
    public void getMeizi(){
        mModel.getMeiziData(new Observer<Meizi>() {
            @Override
            public void onSubscribe(Disposable d) {
                Log.i(TAG, "onSubscribe: ");
            }

            @Override
            public void onNext(Meizi meizi) {
                //下载的数据,传给view
                Log.i(TAG, "onNext: ");
                mView.showMeizi(meizi.getData());
            }

            @Override
            public void onError(Throwable e) {
                Log.i(TAG, "onError: ");
            }

            @Override
            public void onComplete() {

            }
        });
    }
}
